import React from "react";
import { Button } from "./ui/button";

// 这是一个会跑出错误的组件
const BuggyCounter: React.FC = () => {
  const [count, setCount] = React.useState(0);

  if (count === 3) {
    throw new Error("我数到 3 就宕机啦！");
  }

  return (
    <div>
      <p>数字: {count}</p>
      <Button onClick={() => setCount(count + 1)}>点我加 1</Button>
    </div>
  );
};

export default BuggyCounter;
